package es.upm.gib.mappingAPI2;

/**
 * This class represents a coordinate. The first value of the coordinate is the value of the path,
 * and the second one is the position of the class into the path.
 */
public class Coordinate {
    /**
     * Coordinate of the path
     */
    private int path;

    /**
     * Coordinate of the class in the path
     */
    private int class_;

    /**
     * Constructor
     * @param path value of the path
     * @param class_ value of the class
     */
    public Coordinate(int path, int class_){
        this.path = path;
        this.class_ = class_;
    }

    /**
     * This method retrieves the value of the path coordinate
     * @return path coordinate
     */
    public int getPath(){
        return path;
    }

    /**
     * This method retrieves the value of the class coordinate
     * @return class coordinate
     */
    public int getClass_(){
        return class_;
    }

    @Override
    public String toString() {
        return "(" + path + "," + class_ + ")";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Coordinate that = (Coordinate) o;

        if (class_ != that.class_) return false;
        if (path != that.path) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = path;
        result = 31 * result + class_;
        return result;
    }
}
